home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_vol_sophia_cuffed.cog < prev    next >
Text File  |  1999-11-15  |  27KB  |  970 lines

  1. # Jones 3D Cog Script
  2. #
  3. # Vol_Sophia_Cuffed.cog
  4. #
  5. # Indy rescues Sophia from improvised Soviet gulag
  6. #
  7. # [CMG & revised by HB]
  8. #
  9. # (C) 1999 LucasArts Entertainment Co. All Rights Reserved
  10. # ========================================================================================
  11.  
  12. symbols
  13.  
  14. # ................... MESSAGES ...................
  15.  
  16.     message    startup        
  17.     message    activated
  18.     message arrived
  19.     message touched
  20.     message callback    
  21.     message timer    
  22.     message    entered        
  23.     message    exited
  24.     message user0        
  25.  
  26. # ................. KEYFRAMES ....................
  27.  
  28.     keyframe    in_pushHat=0in_figithat_4_4.key            local
  29.     keyframe    in_rtarmup=0in_armsout_1_1.key            local
  30.     keyframe    in_botharmsup=0in_armsup_1_1.key        local
  31.     keyframe    in_Think=0in_thinking_4_4.key            local
  32.     keyframe    in_ltarmup=0in_leftarm_1_1.key            local
  33.     
  34.     keyframe    in_handsSide=0in_stand1.key                local
  35.     keyframe    in_armsCrossed=0in_stand2.key            local
  36.     keyframe    in_handsONhips=0in_stand4.key            local
  37.     keyframe    in_crossArms=0in_stand1_bd_2.key           local
  38.     keyframe    in_handsTOhips=0in_stand1_bd_4.key           local
  39.     keyframe    in_handsTOside=0in_stand4_bd_1.key           local
  40.     keyframe    in_activate=in_activate_medium.key        local
  41.     keyframe    in_overThere=0in_overshoulder_4_1.key    local
  42.     
  43.     keyframe    in_free=in_reach_low.key                local
  44.     keyframe    in_getdown=0in_stand1_bd_6.key            local
  45.     keyframe    in_getup=0in_stand6_bd_1.key            local
  46.     keyframe    in_releasing=0in_stand6.key                local
  47.     keyframe    in_1stand=0in_stand1.key                local
  48.  
  49.     keyframe    in_showkey=0in_key_pull_1_hold.key        local
  50.     keyframe    in_teasekey=0in_key_wave_hold_1.key        local
  51.  
  52.     keyframe    so_standup=0so_getup.key                local
  53.     keyframe    so_lean=0so_getup_stand.key                local
  54.     keyframe    so_rtwave=0so_rightwave_2_2.key            local
  55.     keyframe    so_sitdown=0so_sitdown.key                local
  56. # .................. MODELS ......................
  57.         
  58.     model        mod_in_hand_key=hand_in_cuffkey.3do        local # wrong temp model!!!
  59.  
  60. # ................. SAY LINES ....................
  61.  
  62.     sound    in_line1=VL05J01.WAV                local    #  you ok?
  63.     sound    in_line2=VL05J03.WAV                local    #  like a fish in a net...
  64.     sound    in_line4=VL05J07.WAV                local    #  trust me
  65.     sound    in_line5=VL05J09.WAV                local    #  sorry, not yet
  66.     sound    in_line6=VL05J12.WAV                local    #  workin' on it...
  67.     sound    in_line7=VL05J14.WAV                local    #  ok sophia I found the key
  68.     sound    in_line8=VL05J16.WAV                local    #  be nice, or I won't use it
  69.     sound    in_line9=VL05J18.WAV                local    #  you're right... a gate up ahead...
  70.     sound    in_line10=VL05J20.WAV                local    #  wait!
  71.  
  72.     sound    in_cantopen=Inxj096.wav                local # I can't open it.
  73.     sound    in_nobudge=Inxj098.wav                local # It won't budge.
  74.     sound    in_holdingdoor=Inxj099.wav            local # Something is holding this door closed.
  75.     sound    in_wrongside=Inxj102.wav            local # ...I can't seem to open it from this side.
  76.     
  77.     sound    in_maybe=VL05J05C.WAV                local    # maybe...sit tight...
  78.     
  79.     sound    so_line1=VL05S02.WAV                local    #  how do I look?
  80.     sound    so_line2=VL05S04A.WAV                local    #  find the key...
  81.     sound    so_line3=VL05S06.WAV                local    #  don't let me down jones...
  82.     sound    so_line4=VL05S08.WAV                local    #  got the key?
  83.     sound    so_line5=VL05S10.WAV                local    #  check the guards, knave!
  84.     sound    so_line6=VL05S11.WAV                local    #  the key?
  85.     sound    so_line7=VL05S13.WAV                local    #  work on the guards, ok?
  86.     sound    so_line8=VL05S15.WAV                local    #  took you long enough...
  87.     sound    so_line9=VL05S17.WAV                local    #  you better. you need my help
  88.     sound    so_line10=VL05S19.WAV                local    #  thanks...Now I'm gonna look around
  89.     sound    so_line11=VL05S21.WAV                local    #  see you soon...
  90.     
  91.  
  92.     sound    free_cue=mus_vol_sophia1.wav        local    #  music cue
  93.  
  94. # ............... SOUND EFFECTS ..................
  95.  
  96.     sound    creak=shs_creaky_a2.wav                local
  97.     sound    unlatch=tem_monkeykey_unlock_c.wav    local
  98.  
  99. # .................. OBJECTS .....................    
  100.  
  101.     thing    door0        
  102.     thing    Light_All                            nolink    
  103.     
  104.     thing    leftfence                            nolink
  105.     thing    rightfence                            nolink
  106.     thing    sophiacrate                            nolink
  107.     thing    lock
  108.  
  109. # .................. ACTORS ......................
  110.  
  111.     thing    player                                local        
  112.     thing    sophia        
  113.     thing    indy        
  114.     #thing    commie                                
  115.     thing    talktarget
  116.     
  117.     surface    player_barrier
  118.  
  119. # ............ ACTOR TARGET THINGS ...............
  120.  
  121.     thing    in_mk_1                                nolink
  122.     thing    in_mk_2                                nolink
  123.     thing    in_mk_3                                nolink
  124.     thing    in_mk_4                                nolink
  125.  
  126.     thing    so_exitmark_1                        nolink        
  127.     thing    so_exitmark_2                        nolink
  128.     thing    so_exitmark_3                        nolink
  129.     thing    so_exitmark_4                        nolink
  130.     thing    so_exitmark_5                        nolink
  131.  
  132. # .............. CAMERA THINGS ...................
  133.  
  134.     thing    uncuffCam                            nolink
  135.     thing    unlockCam                            nolink    
  136.     thing    exitCam                                nolink
  137.         
  138.     thing    indycam_1                            nolink
  139.     thing    indycam_2                            nolink
  140.  
  141.     thing    sophiaCam_1                            nolink
  142.     thing    sophiaCam_2                            nolink
  143.  
  144.     thing    poscam                                nolink # use only to swing follow-cam
  145.  
  146. # ........... CAMERA TARGET THINGS ...............
  147.     
  148.     thing    ct_1                                nolink
  149.     thing    ct_2                                nolink
  150.     thing    ct_3                                nolink
  151.     thing    ct_4                                nolink
  152.  
  153.     thing    thingCamTarget                        local # created on the fly
  154.  
  155. # .................... COGS ......................
  156.  
  157.     cog        bridgecog
  158.     cog        doortalkcog
  159.  
  160. # ...... MISCELLANEOUS ENGINE WEIRDNESS ..........
  161.  
  162.     sector    doorSector                            local
  163.     sector    inside           
  164.     sector    outside            
  165.     sector    sceneSect
  166.     
  167.     template    key                                local
  168.     template    ghostTpl=ghost                    local
  169.             
  170. # ................. ROUTINES ....................
  171.     flex    freedom                                local
  172.     flex    randstucklines                        local
  173.  
  174. # ................. VARIABLES ....................
  175.  
  176.     vector    v_campos                            local
  177.     vector    v_targetpos                            local # final target position
  178.     vector    v_closedoorPYR                        local # door aim
  179.     vector    v_arrdoorPYR                        local
  180.     vector    v_tchdoorPYR                        local
  181.     vector    v_dpos                                local # door position
  182.     vector    v_ipos                                local # indy position
  183.     vector    v_idvec                                local # indy-to-door vec
  184.     vector    v_drvec                                local # door right vec
  185.  
  186.     flex    f_arrdoorY                            local # door yaw
  187.     flex    f_tchdoorY                            local
  188.     flex    f_iposcheck                            local # dot result indy relative to door    
  189.     flex    doortime=3.0                        local # define
  190.     flex    sleepTime=1.0                        local # define
  191.     flex    dooryaw                                local
  192.     flex    timeratio                            local
  193.     flex    reopentime                            local
  194.     flex    sophiaStandTime                        local
  195.     flex    in_rotRate                            local
  196.     flex    in_minHeadPitch                        local
  197.     flex    in_headRate                            local
  198.     flex    so_rotRate                            local 
  199.     flex    so_headRate                            local 
  200.  
  201.     int        curCam                                local
  202.     int        curSound                            local
  203.     
  204.     int        in_keyTrack1                        local
  205.     int        so_keyTrack1                        local    
  206.  
  207.     int        openState=0                            local
  208.     int        checked=0                            local
  209.     int        freed=0                                local
  210.     int        talkState=0                            local
  211.     int        sophiastanding=0                    local
  212.     int        newline=0                            local
  213.     int        oldline=0                            local
  214.     int        swapokay=0                            local
  215.     int        alreadytouched=0                    local
  216.     int        alreadyactivated=0                    local
  217.     int        keygrumble=0                        local
  218.  
  219.     int        crateCollType                        local
  220.     int        fenceCollType                        local
  221.     int        indyCollType                        local
  222.     int        lightCollType                        local
  223.  
  224.     int        timerID=1                            local # define
  225.     int        russKey=110                            local # item define
  226.     int        whichItem                            local
  227.     int        swapRef                                local
  228.     int        sender                                local
  229.     int        source                                local
  230.  
  231. end
  232.  
  233. # ========================================================================================
  234.  
  235. code
  236.  
  237. # ........................................................................................
  238.  
  239. startup:
  240.     
  241.     # General prep...
  242.     player = GetLocalPlayerThing();
  243.     doorSector = GetThingSector(door0);
  244.     SetSectorAdjoins(doorSector, 0);
  245.     talkstate = 0; # superstition
  246.  
  247.     # Prep actors...
  248.     in_rotRate = GetThingMaxRotVel(indy);
  249.     so_rotRate = GetThingMaxRotVel(sophia);
  250.     in_headRate = GetThingMaxHeadVel(indy);
  251.     so_headRate = GetThingMaxHeadVel(sophia);
  252.     in_minHeadPitch = GetThingMinHeadPitch(indy);
  253.     so_keyTrack1 = PlayKey(sophia, so_lean, 2, 0x10, 0); # she leans on crate
  254.     #SetThingFlags(commie, 0x80000);
  255.     ClearThingFlags(sophia, 0x80000);
  256.     # Need better way to make head tracking behave when thing is not looking at Indy    
  257.     AISetCutSceneMode(indy);
  258.     AISetCutSceneMode(sophia); 
  259.  
  260.     # Prep set...
  261.     crateCollType = GetCollideType(sophiacrate);
  262.     fenceCollType = GetCollideType(leftfence);
  263.     indyCollType = GetCollideType(indy);
  264.     lightCollType = GetCollideType(Light_All);
  265.     v_closedoorPYR = GetThingLVecPYR(door0);
  266.     SetCollideType(rightfence, 0);
  267.     SetCollideType(leftfence, 0);
  268.     
  269.     return;
  270.  
  271. # ........................................................................................
  272.  
  273. activated:    
  274.     
  275.     sender = GetSenderRef();
  276.     source = GetSourceRef();
  277.  
  278.     if ((sender != door0) && (sender != lock) && (sender != talktarget))
  279.     {
  280.         return;
  281.     }
  282.  
  283.     if ((sender == door0) && (GetThingSector(source) == inside))
  284.     {
  285.         # Activate door from inside...
  286.  
  287.         # NOTE:  door0 has 4 states...
  288.         # 1. closed        -->    openState == 0 (init state)
  289.         # 2. opening    --> openState == 1
  290.         # 3. open        -->    openState == 2
  291.         # 4. closing    --> openState == 3
  292.         
  293.         if (openState > 0)
  294.         {
  295.             return;
  296.         }
  297.   
  298.         openState = 1; # door is opening
  299.         alreadytouched = 0; # init every time door opens
  300.         SetSectorAdjoins(doorSector, 1); # start to see thru
  301.         Rotate(door0, 90, 1, doortime);
  302.  
  303.         return;
  304.     }
  305.     else if ((sender == door0) && (GetThingSector(source) == outside))
  306.     {
  307.         # Or activate door from outside...
  308.                      
  309.          if (alreadyactivated > 0)
  310.         {
  311.             return;
  312.         }
  313.  
  314.         if (openState > 0)
  315.         {
  316.             return;
  317.         }
  318.  
  319.         alreadyactivated = 1; # defeat multiple activates    
  320.         curCam = GetCurrentCamera();
  321.         SetExtCamOffsetToThing(poscam);
  322.         MakeMeStop();
  323.         DeselectWeaponWait(player);
  324.         StartCutScene(1);
  325.         
  326.         if (checked == 0)
  327.         {
  328.             # Trick randstucklines so Indy says...
  329.             # ..."won't open from this side" 1st time thru
  330.             newline = 4;
  331.             oldline = 0;
  332.             checked = 1;
  333.         }
  334.         call randstucklines;
  335.  
  336.         RestoreExtCam();
  337.         ClearActorFlags(player, 0x200000);
  338.         EndCutScene();
  339.         alreadyactivated = 0;
  340.  
  341.         return;
  342.     }
  343.         
  344.     if (sender == lock)
  345.     {    
  346.         # Check if inventory is being used...
  347.         whichItem = GetCurItem(player);
  348.         
  349.         # Prep for scene...
  350.         MakeMeStop();
  351.         DeselectWeaponWait(player);
  352.         StartCutScene(1);
  353.  
  354.         KillTimerEx(timerID); # don't let sophia sit during chat
  355.         curCam = GetCurrentCamera();
  356.         SetCameraLookInterp(2, 0);
  357.         SetCameraPosInterp(2, 0);
  358.  
  359.         CopyPlayerHolsters(player, indy);
  360.         SetThingFlags(player, 0x80000);
  361.         ClearThingFlags(indy, 0x80000);
  362.  
  363.         # Line Indy up...
  364.         CopyOrientAndPos(player, indy);
  365.         AISetLookThing(indy, in_mk_4);
  366.         AIWaitForStop(indy);
  367.  
  368.         # Slew follow cam to observe scene
  369.         ### SetExtCamLookOffsetToThing(lock); # new look offset per Matt R...buggy
  370.         SetExtCamOffsetToThing(unlockCam);
  371.         Sleep(0.5);
  372.     
  373.         if (whichItem == russKey)
  374.         {
  375.             ChangeInv(player, russKey, -1);
  376.             call freedom;
  377.  
  378.             return;
  379.         }
  380.         else
  381.         {                                
  382.             if (whichItem != 0)
  383.             {
  384.                 # Take care of wrong keys and items...
  385.                 global15 = 0;
  386.                 SendMessageEx(doortalkcog, user0, indy, russKey, whichItem, 0);
  387.             }
  388.             else
  389.             {
  390.                 if (keygrumble == 0)
  391.                 {
  392.                     # Note need for key 1st time thru...
  393.                     global15 = 0;
  394.                     SendMessageEx(doortalkcog, user4, indy, 1, 3, 0);
  395.                     keygrumble = 1;
  396.                 }
  397.                 else
  398.                 {
  399.                     # General "door is locked" grumbling thereafter...
  400.                     global15 = 0;
  401.                     SendMessageEx(doortalkcog, user4, indy, 0, 0, 0);
  402.                 }
  403.             }
  404.             
  405.             while (global15 == 0)
  406.             {
  407.                 Sleep(0.01); # wait for line to finish
  408.             }
  409.             Sleep(0.3);
  410.             RestoreExtCam();
  411.             SetThingMaxRotVel(indy, in_rotRate);
  412.             SetThingMaxHeadVel(indy, in_headRate);
  413.             SetThingMinHeadPitch(indy, in_minHeadPitch);
  414.             ClearThingFlags(player, 0x80000);
  415.             SetThingFlags(indy, 0x80000);
  416.  
  417.             EndCutScene();
  418.             ClearActorFlags(player, 0x200000);
  419.  
  420.             return;
  421.         }
  422.  
  423.         return;
  424.     }
  425.         
  426.     if (sender == talktarget)
  427.     {        
  428.         # player talks to imprisoned Sophia...
  429.  
  430.         # Prep...
  431.         MakeMeStop();
  432.         DeselectWeaponWait(player);
  433.         StartCutScene(1);
  434.         KillTimerEx(timerID); # don't let sophia sit down during chat
  435.         
  436.         # kill sophia's head tracking
  437.         AIDisableHeadTracking(sophia);
  438.  
  439.         curCam = GetCurrentCamera();
  440.         SetCameraLookInterp(2, 0);
  441.         SetCameraPosInterp(2, 0);
  442.  
  443.         CopyPlayerHolsters(player, indy);
  444.         SetThingFlags(player, 0x80000);
  445.         ClearThingFlags(indy, 0x80000);
  446.  
  447.         # Line Indy up...
  448.         TeleportThing(indy, player);
  449.         AISetLookThing(indy, ct_3);
  450.         AIWaitForStop(indy);
  451.  
  452.         # Slew follow cam to observe scene...
  453.         ### SetExtCamLookOffsetToThing(talktarget); # new look offset per Matt R buggy
  454.         SetExtCamOffsetToThing(uncuffCam);
  455.         Sleep(0.5);
  456.  
  457.         # Conditionally stand Sophia up...
  458.         if (sophiastanding == 0)
  459.         {
  460.             StopKey(sophia, so_keyTrack1, 0.0);
  461.             PlayKey(sophia, so_standup, 4, 0x12, 1);
  462.             SetCollideType(sophiacrate, 0); # so she can turn to watch Indy
  463.             sophiastanding = 1; # take note
  464.         }
  465.  
  466.         # She faces him...
  467.         AISetLookThing(sophia, indy);
  468.         AIWaitForStop(sophia);
  469.  
  470.         # increment to next version of conversation...
  471.         if (talkState < 3)
  472.         {
  473.             talkState = talkState + 1;
  474.         }
  475.  
  476.         if (talkState == 1)
  477.         {
  478.             # Indy: "You okay?"
  479.             PlayVoice(indy, in_line1, 2, 1);
  480.  
  481.             # Sophia: "How do I look?"
  482.             PlayVoice(sophia, so_line1, 2, 1);
  483.  
  484.             # Indy: "Like a fish in a net."
  485.             PlayVoice(indy, in_line2, 2, 1);
  486.  
  487.             # Sophia: "Find the key..."
  488.             PlayVoice(sophia, so_line2, 2, 1);
  489.  
  490.             # Cut to shot of Sophia...
  491.             SetCameraFocus(2, sophiaCam_1);
  492.             SetCameraSecondaryFocus(2, ct_1);
  493.             SetThingFlags(indy, 0x10); # look past Indy
  494.             SetCurrentCamera(2);
  495.             SetCameraFOV(25, 0, 0.0);
  496.             
  497.             # Place Indy on mark while offscreen...
  498.             TeleportThing(indy, in_mk_1);
  499.             Sleep(0.01);
  500.             AISetLookThing(indy, sophia);
  501.             AISetLookThing(sophia, indy);
  502.             AIWaitForStop(sophia);
  503.  
  504.             # Sophia: "Don't let me down, Jones..."
  505.             curSound = PlayVoice(sophia, so_line3, 1.5, 0);
  506.             Sleep(2.0);
  507.  
  508.             # Start Indy gestures...
  509.             in_keyTrack1 = PlayKey(indy, in_handsONhips, 2, 0x10, 0);
  510.             PlayKey(indy, in_handsTOhips, 4, 0x12, 0);
  511.             WaitForSound(curSound);
  512.         
  513.             # Cut to close-up of Indy...
  514.             ClearThingFlags(indy, 0x10); # see Indy again
  515.             SetThingFlags(sophia, 0x10); # don't see Sophia
  516.             SetThingFlags(leftfence, 0x10); # don't see fence    
  517.             SetCameraFocus(2, indycam_1);
  518.             SetCameraSecondaryFocus(2, ct_2);
  519.             SetCameraFOV(25, 0, 0.0);
  520.  
  521.             # Indy: "Trust me."
  522.             PlayKey(indy, in_pushHat, 4, 0x12, 0);
  523.             Sleep(1.0);
  524.             curSound = PlayVoice(indy, in_line4, 1.5, 0);
  525.             WaitForSound(curSound);
  526.             Sleep(0.7);
  527.             StopKey(indy, in_keyTrack1, 0.5);
  528.             Sleep(0.5);
  529.             
  530.             # Back to follow-cam...
  531.             ClearThingFlags(sophia, 0x10); # restore visibility
  532.             ClearThingFlags(leftfence, 0x10);
  533.             SetCAmeraPosition(1, GetThingPos(uncuffcam));
  534.             SetCurrentCamera(curCam);
  535.             ResetCameraFOV(0, 0.0);        
  536.         }
  537.  
  538.         if ((talkState == 2) && (GetInv(player, russKey) == 0))
  539.         {
  540.             # Sophia: "Got the key?"
  541.             PlayVoice(sophia, so_line4, 1.5, 1);
  542.             
  543.             # Indy: "Sorry, not yet."
  544.             PlayVoice(indy, in_line5, 1.5, 1);
  545.  
  546.             # Sophia: "Check the guards..."
  547.             PlayVoice(sophia, so_line5, 1.5, 1);
  548.         }
  549.  
  550.         if ((talkState == 3) && (GetInv(player, russKey) == 0))
  551.         {
  552.             # Sophia: "The key..."
  553.             PlayVoice(sophia, so_line6, 1.5, 1);
  554.  
  555.             # Indy: "Working on it."
  556.             PlayVoice(indy, in_line6, 1.5, 1);
  557.  
  558.             # Sophia: "Work on the guards, okay?"
  559.             PlayVoice(sophia, so_line7, 1.5, 1);
  560.         }
  561.  
  562.         if ((talkState > 1) && (GetInv(player, russKey) == 1))
  563.         {
  564.             # Sophia: "The key...?"
  565.             PlayVoice(sophia, so_line6, 1.5, 1);
  566.             
  567.             # Indy: "Maybe. Sit tight."
  568.             PlayVoice(indy, in_maybe, 1.5, 1);
  569.         }
  570.     }
  571.  
  572.     # Common clean-up...
  573.     ClearThingFlags(player, 0x80000);
  574.     SetThingFlags(indy, 0x80000);
  575.     RestoreExtCam();
  576.     EndCutScene();
  577.     ClearActorFlags(player, 0x200000);
  578.     
  579.     # After a while Sophia sits down again...
  580.     AIClearCutSceneMode(sophia);
  581.     AIClearCutSceneMode(indy);
  582.     sophiaStandTime = ((4.0 * Rand()) + 7.0);
  583.     SetTimerEx(sophiaStandTime, timerID, 0.0, 0.0); # get ready to relax sophia
  584.  
  585.     return;
  586.  
  587. # ........................................................................................
  588.  
  589. freedom:
  590.  
  591.     # Indy: "Okay, I got the key..."
  592.     curSound = PlayVoice(indy, in_line7, 2, 0);
  593.  
  594.     # PLay Music
  595.     PlaySoundLocal(free_cue, 0.5, 0, 0x0, 0);
  596.  
  597.     # Swap in hand with key...
  598.     swapokay = 1;
  599.     in_keyTrack1 = PlayKey(indy, in_showkey, 4, 0x14, 0); # this anim marked @ frm15
  600.  
  601.     # Prep for action...
  602.     DestroyThing(talktarget);
  603.     DestroyThing(lock);
  604.     SetCollideType(sophiacrate, 0);
  605.     SetCollideType(rightfence, 0);
  606.     SetCollideType(leftfence, 0);
  607.     SetCollideType(indy, 0);
  608.     SetCollideType(Light_All, 0);
  609.  
  610.     # Conditionally stand Sophia up...
  611.     if (sophiastanding == 0)
  612.     {
  613.         StopKey(sophia, so_keyTrack1, 0.0);
  614.         PlayKey(sophia, so_standup, 4, 0x12, 1);
  615.     }
  616.  
  617.     # clear the no move flag off the player_barrier
  618.     SetAdjoinFlags(player_barrier, 2);
  619.     SetAdjoinFlags(GetSurfaceAdjoin(player_barrier), 2); 
  620.     
  621.     # She walks over to Indy...
  622.     AISetLookThingEyeLevel(sophia, so_exitmark_1);
  623.     AIEnableHeadTracking(sophia, indy);
  624.     
  625.     SetThingMaxRotVel(sophia, 300.0);
  626.     SetThingMaxHeadVel(sophia, 250.0);
  627.     AIWaitForStop(sophia);
  628.     AISetMoveSpeed(sophia, 1.0);
  629.     AISetMoveThing(sophia, so_exitmark_1, 0);
  630.     WaitForSound(curSound);
  631.  
  632.     # Sophia: "Took you long enough."
  633.     curSound = PlayVoice(sophia, so_line8, 2, 0);
  634.     AIWaitForStop(sophia);
  635.     AIDisableHeadTracking(sophia);  // disable so you won't see her head move when indy gets warped to new mark below
  636.     
  637.     AISetLookThing(sophia, indy);
  638.     WaitForSound(curSound);
  639.     
  640.     # Indy: "Be nice, or I won't use it."
  641.     StopKey(indy, in_keyTrack1, 0.0);
  642.     in_keyTrack1 = PlayKey(indy, in_teasekey, 4, 0x14, 0);
  643.     PlayVoice(indy, in_line8, 2, 1);
  644.     
  645.     # Cut to single on Sophia...
  646.     AISetLookThingEyeLevel(sophia, in_mk_2); // focus sophia on spot indy is about to warp to
  647.     SetCameraFocus(2, sophiaCam_2);
  648.     SetCameraSecondaryFocus(2, ct_3);
  649.     SetThingFlags(indy, 0x10); # no Indy
  650.     SetCurrentCamera(2);
  651.     SetCameraFOV(25, 0, 0.0);
  652.     
  653.     # Place Indy on mark while offscreen...
  654.     StopKey(indy, in_keyTrack1, 0.0);
  655.     RestoreThingMesh(indy, swapRef); # swap key back out
  656.     swapokay = 0;
  657.     CopyOrientAndPos(in_mk_2, indy);
  658.     AISetLookThing(indy, sophia); // look at her from new position
  659.  
  660.     # Sophia: "You better.  You need my help."
  661.     curSound = PlayVoice(sophia, so_line9, 2, 0);
  662.     Sleep(2.0);
  663.     in_keyTrack1 = PlayKey(indy, in_handsONhips, 2, 0x10, 0);
  664.     PlayKey(indy, in_handsTOhips, 4, 0x12, 0);
  665.     WaitForSound(curSound);
  666.  
  667.     # Reverse on Indy...
  668.     ClearThingFlags(indy, 0x10); # see Indy
  669.     SetThingFlags(sophia, 0x10); # don't see Sophia
  670.     SetThingFlags(leftfence, 0x10); # don't see fence    
  671.     SetThingFlags(rightfence, 0x10);    
  672.     SetCameraFocus(2, indycam_2);
  673.     SetCameraSecondaryFocus(2, ct_4);
  674.     SetCameraFOV(35, 0, 0.0);
  675.     AISetLookThing(sophia, indy); // refocus on Indy's new position while offscreen
  676.  
  677.     # Indy: "You're right about that...gate up ahead..."
  678.     curSound = PlayVoice(indy, in_line9, 2, 0);
  679.     Sleep(1.0);
  680.     StopKey(indy, in_keyTrack1, 0.0);
  681.     PlayKey(indy, in_overThere, 4, 0x12, 1);
  682.     PlayKey(indy, in_activate, 4, 0x12, 0);
  683.     Sleep(0.5);
  684.  
  685.      # Cut to wider view of scene as Indy unlocks the fence door...
  686.     ClearThingFlags(sophia, 0x10); # Sophia back
  687.     ClearThingFlags(leftfence, 0x10); # fence back    
  688.     ClearThingFlags(rightfence, 0x10);
  689.     
  690.     # Make a target near Sophia...
  691.     v_targetpos =
  692.         VectorAdd(VectorTransformToOrient(sophia, '0.07 0.005 0.035'), GetThingPos(sophia));     
  693.     thingCamTarget = 
  694.         CreateThingAtPos(ghostTpl, GetThingSector(sophia), v_targetpos, '0 0 0');
  695.     CaptureThing(thingCamTarget);
  696.  
  697.     AttachThingToThing(thingCamTarget, sophia); # track her move
  698.     SetCameraFocus(2, exitCam);    
  699.     SetCameraSecondaryFocus(2, thingCamTarget);
  700.     SetCameraFOV(70, 0, 0.0);
  701.  
  702.     # Indy opens the makeshift cell...
  703.     Rotate(rightfence, -90, 1, 1.5);
  704.     PlaySoundLocal(unlatch, 1.0, 0, 0x0, 0);
  705.     Sleep(0.5);
  706.  
  707.     # Sophia: "Thanks, Indy...I'm going to take a good look..."
  708.     PlayVoice(sophia, so_line10, 2, 0);
  709.     Sleep(0.5);
  710.     
  711.     # Sophia on the move...
  712.     AISetMoveSpeed(sophia, 1.2);
  713.     SetThingMaxRotVel(sophia, so_rotRate);// back to full speed
  714.     SetThingMaxHeadVel(sophia, so_headRate);
  715.     Sleep(0.01);
  716.     AISetLookThingEyeLevel(sophia, so_exitmark_2);
  717.     AISetMoveThing(sophia, so_exitmark_2, 0);
  718.     SetThingMaxHeadVel(indy, 120.0); // slower for watching sophia pass
  719.     AIEnableHeadTracking(indy, sophia);
  720.     Sleep(0.3);
  721.     
  722.     # Indy starts to turn body to keep sophia in sight
  723.     SetThingMaxRotVel(indy, 60.0); // slower for turning as sophia passes
  724.     # Because sophia "crashes" through indy, his head pitches down considerably
  725.     # Set min pitch to mostly flat to hide problem
  726.     SetThingMinHeadPitch(indy, -2.0);
  727.     AIEnableBodyTracking(indy, sophia);
  728.     
  729.     # Stay on Sophia as she moves out...
  730.     SetCameraFOV(50, 1, 3.0);
  731.        AISetLookThing(sophia, so_exitmark_3);
  732.     AISetMoveThing(sophia, so_exitmark_3, 0);
  733.  
  734.     # Indy starts to follow after aesthetic delay
  735.     # Head and body tracking of sophia by Indy still operational
  736.     Sleep(2.5); # delay move for a moment
  737.     AISetMoveSpeed(indy, 1.1);
  738.     AISetMoveThing(indy, in_mk_3, 0);
  739.     Sleep(1.6);
  740.  
  741.     # Indy: "Wait..."
  742.     PlayVoice(indy, in_line10, 2, 0);
  743.  
  744.     # Sophia stops & turns...
  745.     AIWaitForStop(sophia);
  746.     AISetLookThing(sophia, indy);
  747.     AIWaitForStop(sophia);
  748.     
  749.     # Sophia: "See you soon."
  750.     curSound = PlayVoice(sophia, so_line11, 2, 0);
  751.     PlayKey(sophia, so_rtwave, 4, 0x12, 0);
  752.  
  753.     # Indy stops...
  754.     AIDisableBodyTracking(indy);
  755.     AISetLookThing(indy, sophia);
  756.     AISetMoveSpeed(indy, 0);
  757.     WaitForSound(curSound);
  758.                 
  759.     # Sophia departs...
  760.     DetachThing(thingCamTarget); # hold camera frame
  761.     AISetMoveSpeed(sophia, 3.2); # she breaks into a run
  762.     AISetLookThing(sophia, so_exitmark_4);
  763.     AISetMoveThing(sophia, so_exitmark_4, 0);
  764.     AIWaitForStop(sophia);
  765.     AIDisableHeadTracking(indy);
  766.     
  767.     # Open the door...
  768.     openState = 1;
  769.     alreadytouched = 0;
  770.     SetSectorAdjoins(doorSector, 1); # see thru
  771.     Rotate(door0, 90, 1, doortime);
  772.     AISetMoveThing(sophia, so_exitmark_5, 0);
  773.     
  774.     # Clean up...
  775.     SetCollideType(sophiacrate, crateCollType);
  776.     SetCollideType(rightfence, fenceCollType);
  777.     SetCollideType(leftfence, fenceCollType);
  778.     SetCollideType(indy, indyCollType);
  779.     SetCollideType(Light_All, lightCollType);
  780.     CopyOrientAndPos(indy, player);
  781.     Sleep(3.0); # was 1.0
  782.  
  783.     # Restore control...
  784.     v_campos = GetThingPOS(exitCam);
  785.     SetCameraPosition(1, v_campos); # prep to swing back to follow-cam
  786.     SetCurrentCamera(curCam);
  787.     ResetCameraFOV(0, 0.0);
  788.     RestoreExtCam();
  789.     SetThingMaxRotVel(indy, in_rotRate);
  790.     SetThingMinHeadPitch(indy, in_minHeadPitch);
  791.     ClearThingFlags(player, 0x80000);
  792.     SetThingFlags(indy, 0x80000);
  793.  
  794.     AIClearCutSceneMode(sophia);
  795.     AIClearCutSceneMode(indy);
  796.  
  797.     # When next we see our heroine, she'll be waiting on the bridge...
  798.     DestroyThing(sophia); # don't let Indy meet her by mistake
  799.     DestroyThing(thingCamTarget);
  800.     SendMessage(bridgecog, user0);
  801.  
  802.     # Return control to player...
  803.     EndCutScene();
  804.     ClearActorFlags(player, 0x200000);
  805.     
  806.     return;
  807.  
  808. # ...................................................................
  809.  
  810. callback:
  811.  
  812.     if (GetSenderRef() == indy)
  813.     {
  814.         if (swapokay == 1)
  815.         {
  816.             # Swap key...
  817.             swapRef = SetThingMesh(indy, 15, mod_in_hand_key, 0);
  818.         }
  819.     }
  820.  
  821.     return;
  822.  
  823. # ...................................................................
  824.  
  825. arrived:
  826.  
  827.     if (GetSenderRef() == door0 && openState == 1)
  828.     {
  829.         openState = 2; # door is now open
  830.         Sleep(sleeptime);
  831.  
  832.         # Close door...
  833.         Rotate(door0, -90, 1, doortime);
  834.         openState = 3; # door is closing
  835.         alreadytouched = 0; # Indy can stop it again
  836.     }
  837.  
  838.     if (GetSenderRef() == door0 && openState == 3)
  839.     {
  840.         v_arrdoorPYR = GetThingLVecPYR(door0);
  841.         f_arrdoorY = Truncate(VectorY(v_arrdoorPYR)); # to lowest integer degree
  842.  
  843.         if (f_arrdoorY == 0)
  844.         {
  845.         SetThingLVecPYR(door0, v_closedoorPYR); # slam it closed for sure
  846.         SetSectorAdjoins(doorSector, 0); # no see thru
  847.         openState = 0; # door is now closed
  848.         }
  849.     }
  850.  
  851.     return;
  852.  
  853. # ...................................................................
  854.  
  855. touched:
  856.         
  857.     if ((GetSenderRef() == talktarget) && (talkState == 0))
  858.     {
  859.         # as if...
  860.         goto activated;
  861.     }
  862.  
  863.     if (alreadytouched > 0 || openState != 3)
  864.     {
  865.         return;
  866.     }
  867.  
  868.     if (GetSenderRef() == door0 && openState == 3)
  869.     {
  870.         alreadytouched = 1; # do once only
  871.     
  872.         # check if Indy is touching back side of door...
  873.         v_dpos = GetThingPos(door0); # door hinge
  874.         v_ipos = GetThingPos(player); # our hero
  875.          v_idvec = VectorNorm(VectorSub(v_dpos, v_ipos)); # direction between indy & door 
  876.         v_drvec = GetThingLVec(door0); # check 90 to door plane
  877.         f_iposcheck = VectorDot(v_idvec, v_drvec); # places indy in- or outside door
  878.     
  879.         if (f_iposcheck > 0)
  880.         {
  881.             # Don't re-open if Indy is touching back side...
  882.             return;
  883.         }    
  884.         
  885.         StopThing(door0);
  886.         Sleep(0.1); # let engine update
  887.         v_tchdoorPYR = GetThingLVecPYR(door0);
  888.         dooryaw = (90 - Abs(VectorY(v_tchdoorPYR))); # how far is door open?
  889.         timeratio = (dooryaw / 90); # what percentage?
  890.         reopentime = ( doortime * timeratio); # calculate time
  891.         Rotate(door0, dooryaw, 1, reopentime); # re-open 
  892.         openState = 1; # door is opening again
  893.     }
  894.  
  895.     return;
  896.  
  897. # ........................................................................................
  898.  
  899. entered:
  900.  
  901.     if (GetSenderRef() == sceneSect)
  902.     {
  903.         AIEnableHeadTracking(sophia, player);
  904.     }
  905.  
  906.     return;
  907.         
  908. # ........................................................................................
  909.  
  910. exited:
  911.  
  912.     if (GetSenderRef() == sceneSect)
  913.     {
  914.         AIDisableHeadTracking(sophia);
  915.     }
  916.  
  917.     return;
  918.  
  919. # ........................................................................................
  920.  
  921. timer:
  922.  
  923.     AISetMode(sophia, 0x2000); # don't watch Indy from relaxed pose
  924.     StopKey(sophia, so_keyTrack1, 0.0);
  925.     AISetLookThing(sophia, in_mk_3); # orient correctly
  926.     AIWaitForStop(sophia);
  927.     so_keyTrack1 = PlayKey(sophia, so_lean, 2, 0x10, 0);
  928.     PlayKey(sophia, so_sitdown, 4, 0x12, 0); # should be return to lean
  929.     SetCollideType(sophiacrate, crateCollType);
  930.     sophiastanding = 0; # she's sitting again
  931.     
  932.     # re-establish sophia head tracking
  933.     AIEnableHeadTracking(sophia, player);
  934.  
  935.     return;
  936.  
  937. # ..............................................................................
  938.  
  939. randstucklines:
  940.  
  941.     while (newline == oldline)
  942.     {    
  943.         newline = RandBetween(1, 4); # pick new line
  944.     }
  945.     oldline = newline; # remember what got picked
  946.  
  947.     if (newline == 1)
  948.     {
  949.         curSound = PlayVoice(player, in_cantopen, 1.0, 0);
  950.     }    
  951.     if (newline == 2)
  952.     {
  953.         curSound = PlayVoice(player, in_nobudge, 1.0, 0);
  954.     }
  955.     if (newline == 3)
  956.     {
  957.         curSound = PlayVoice(player, in_holdingdoor, 1.0, 0);
  958.     }
  959.     if (newline == 4)
  960.     {
  961.         curSound = PlayVoice(player, in_wrongside, 1.0, 0);
  962.     }
  963.     WaitForSound(curSound);
  964.     Sleep(0.5);
  965.  
  966.     return;
  967.  
  968. end
  969.  
  970.